<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			firstName: <input type="text" v-model="firstname">
			lastName: <input type="text" v-model='lastname'>
			 
			fullName:{{fullName}} <br>
			 
		</div>
		<script>
			let vm = new Vue({
				el: '#app',
				data: {
					firstname: '',
					lastname: '',
					fullName: '' ,
				},
				watch:{
					//val表示firstname改变的新值
					firstname: function(val){
						this.fullName=val+' '+this.lastname;
					},
					lastname: function(val){
						this.fullName=this.firstname+' '+val;
					}
				}
				 
			});
		</script>
	</body>
</html>
